[AWSX-2144] feat(go-forwarder): add basic api key and config logic#1084
Conversation
|
|
||
| if err := cfg.resolveAPIKey(ctx); err != nil { | ||
| return nil, fmt.Errorf("resolving API key: %w", err) | ||
| } | ||
|
|
| # SAM | ||
| .PHONY: build-ForwarderFunction sam-build sam-invoke sam-deploy | ||
|
|
||
| build-ForwarderFunction: |
There was a problem hiding this comment.
💬 suggestion: Are we allowed to change case here? Can we stick to kebab-case? It's a mix of PascalCase and kebab-case that is disturbing.
There was a problem hiding this comment.
This command is (and should only be) used by the sam build command, which use whatever is written after build- to create a function named ForwarderFunction in the cloudformation template (local).
| func TestLoadConfig(t *testing.T) { | ||
| tests := map[string]struct { |
There was a problem hiding this comment.
| func TestLoadConfig(t *testing.T) { | |
| tests := map[string]struct { | |
| func TestLoadConfig(t *testing.T) { | |
| t.Parallel() | |
| tests := map[string]struct { |
There was a problem hiding this comment.
t.Parallel() cannot be used with t.Setenv(k,v) since the latter affects the whole process.
| if !ok { | ||
| return fallback | ||
| } | ||
| return strings.EqualFold(v, "true") |
There was a problem hiding this comment.
💭 thought: I'm wondering if we should support the "1" value etc?
You might prefere using ParseBool that will handle everything for you.
There was a problem hiding this comment.
We lose nothing by doing so. Let's use it.
|
|
||
| package config | ||
|
|
||
| //go:generate go tool mockgen -source=secretsmanager.go -package=config -destination=secretsmanager_mockgen.go |
There was a problem hiding this comment.
We'll move the mock to a dedicated package later I think, to not have be part of the production bundle. Ok for now
Co-authored-by: Vincent Boutour <vincent.boutour@datadoghq.com>
Co-authored-by: Vincent Boutour <vincent.boutour@datadoghq.com>
Co-authored-by: Vincent Boutour <vincent.boutour@datadoghq.com>
Co-authored-by: Vincent Boutour <vincent.boutour@datadoghq.com>
What does this PR do?
Add the logging initialization, the configuration, the api key retrieval/verification strategies and their tests.
Motivation
Following the migration of the Log Forwarder to Go, the logging, the api key retrieval/verification and the loading/declaration of the configuration are required to test the most basic version of the new forwarder.
Testing Guidelines
Additional Notes
HTTP_PROXYandHTTPS_PROXYenvironment variables. We will probably deprecate the SSL skipping related flags for now.Types of changes
Check all that apply